package com.li.design;  
/**  
* 类说明   
*  
* @author ****  
* @date 2018年4月1日  新建  
*/
public class AbstractFactory {
	interface OutLookFactory{
		Clothes createClothes();
		Hat createHat();
	}
	
	static class OutLookFactoryProducer{
		static OutLookFactory getFactory(String o){
			OutLookFactory pf = null;
			if(o.equals("normal")){
				pf =  new NormalFactory();
			}else if(o.equals("vip")){
				pf =  new VipFactory();
			}
			return pf;
		}
	}
	
	static class NormalFactory implements OutLookFactory{

		@Override
		public Clothes createClothes() {
			// TODO Auto-generated method stub
			return new NorMalClothes();
		}

		@Override
		public Hat createHat() {
			// TODO Auto-generated method stub
			return new NormalHat();
		}
	}
	
	static class VipFactory implements OutLookFactory{

		@Override
		public Clothes createClothes() {
			// TODO Auto-generated method stub
			return new VipClothes();
		}

		@Override
		public Hat createHat() {
			// TODO Auto-generated method stub
			return new VipHat();
		}
	}
	
	interface Clothes{
		void showChothes();
	}
	
	interface Hat{
		void showHat();
	}
	
	static class NorMalClothes implements Clothes{

		@Override
		public void showChothes() {
			// TODO Auto-generated method stub
			System.out.println("show normal clothes");
		}
	}
	
	static class VipClothes implements Clothes{

		@Override
		public void showChothes() {
			// TODO Auto-generated method stub
			System.out.println("show vip clothes");
		}
	}
	
	static class NormalHat implements Hat{

		@Override
		public void showHat() {
			// TODO Auto-generated method stub
			System.out.println("show normal hat");
		}
		
	}
	
	static class VipHat implements Hat{

		@Override
		public void showHat() {
			// TODO Auto-generated method stub
			System.out.println("show vip hat");
		}
	}
	
	public static void main(String[] args) {
		OutLookFactory of = OutLookFactoryProducer.getFactory("vip");
		Clothes c = of.createClothes();
		c.showChothes();
	}
}
  